package com.team1.supervend.domain;

public class CreditPaymentAuthorizationServiceFactory {
	private static CreditPaymentAuthorizationServiceFactory instance;
	public IPaymentAuthorizationServiceAdapter paymentAuthorizationServiceAdapter;

	public static synchronized CreditPaymentAuthorizationServiceFactory getInstance()
	{
		if ( instance == null )
		{
			instance = new CreditPaymentAuthorizationServiceFactory();
    	}
		return instance;
	}

	public IPaymentAuthorizationServiceAdapter getPaymentAuthorizationServiceAdapter() 
	{
		if ( paymentAuthorizationServiceAdapter == null )
		{
			String className = System.getProperty( "paymentAuthorizationService.class.name" );
			try 
			{
				paymentAuthorizationServiceAdapter = (IPaymentAuthorizationServiceAdapter)Class.forName(className).newInstance();
			} 
			catch ( InstantiationException e ) 
			{
				e.printStackTrace();
		    } 
			catch ( IllegalAccessException e ) 
			{
		    	e.printStackTrace();
			} 
			catch ( ClassNotFoundException e ) 
			{
		    	e.printStackTrace();
			}
		}
		return paymentAuthorizationServiceAdapter;	
	}


}
